package com.suneast.suneaststore.modules.goodsdetail.adapter;

import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.suneast.suneaststore.R;
import com.suneast.suneaststore.bean.goodsdetail.SpecsDataBean;
import com.suneast.suneaststore.modules.goodsdetail.event.SpecsItemCheckChanged;
import com.suneast.suneaststore.ui.customview.ZzCheckBox;

import org.greenrobot.eventbus.EventBus;

import java.util.List;

public class SpecsItemAdapter extends BaseQuickAdapter<SpecsDataBean.SpecsBean.ItemsBean, BaseViewHolder> {
    public SpecsItemAdapter(int layoutResId, @Nullable List<SpecsDataBean.SpecsBean.ItemsBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, SpecsDataBean.SpecsBean.ItemsBean item) {
        ZzCheckBox cb = helper.getView(R.id.cb_specs);
        cb.setText(item.getTitle());
        cb.setOnCheckedChangeListener((View v, boolean isChecked) -> {
            EventBus.getDefault().post(new SpecsItemCheckChanged(isChecked,item));
        });
    }
}
